int l, io_index;
uint8_t *ptr;
uint32_t val;
-
+
+#if defined(__i386__) || defined(__x86_64__)
+ static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
+ pthread_mutex_lock(&mutex);
+#endif
+
while (len > 0) {
/* How much can we copy before the next page boundary? */
l = TARGET_PAGE_SIZE - (addr & ~TARGET_PAGE_MASK);
buf += l;
addr += l;
}
+
+#if defined(__i386__) || defined(__x86_64__)
+ pthread_mutex_unlock(&mutex);
+#endif
}
#endif
if (nr_pages < max_pages)
max_pages = nr_pages;
- nr_buckets = (max_pages << PAGE_SHIFT) >> MCACHE_BUCKET_SHIFT;
-
+ nr_buckets = max_pages + (1UL << (MCACHE_BUCKET_SHIFT - PAGE_SHIFT)) - 1;
+ nr_buckets >>= (MCACHE_BUCKET_SHIFT - PAGE_SHIFT);
fprintf(logfile, "qemu_map_cache_init nr_buckets = %lx\n", nr_buckets);
mapcache_entry = malloc(nr_buckets * sizeof(struct map_cache));
entry = &mapcache_entry[address_index % nr_buckets];
- if (entry->vaddr_base == NULL || entry->paddr_index != address_index)
- {
+ if (entry->vaddr_base == NULL || entry->paddr_index != address_index) {
/* We need to remap a bucket. */
uint8_t *vaddr_base;
unsigned long pfns[MCACHE_BUCKET_SIZE >> PAGE_SHIFT];